

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function insertAfter(newElement,targetElement) {
  var parent = targetElement.parentNode;
  if (parent.lastChild == targetElement) {
    parent.appendChild(newElement);
  } else {
    parent.insertBefore(newElement,targetElement.nextSibling);
  }
}

function addClass(element,value) {
  if (!element.className) {
    element.className = value;
  } else {
    newClassName = element.className;
    newClassName+= " ";
    newClassName+= value;
    element.className = newClassName;
  }
}

function initRollovers() {
    if (!document.getElementById) return
    
    var aPreLoad = new Array();
    var sTempSrc;
    var aImages = document.getElementsByTagName('img');

    for (var i = 0; i < aImages.length; i++) {        
        if (aImages[i].className == 'imgover') {
            var src = aImages[i].getAttribute('src');
            var ftype = src.substring(src.lastIndexOf('.'), src.length);
            var hsrc = src.replace(ftype, '_on'+ftype);

            aImages[i].setAttribute('hsrc', hsrc);
            
            aPreLoad[i] = new Image();
            aPreLoad[i].src = hsrc;
            
            aImages[i].onmouseover = function() {
                sTempSrc = this.getAttribute('src');
                this.setAttribute('src', this.getAttribute('hsrc'));
            }    
            
            aImages[i].onmouseout = function() {
                if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
                this.setAttribute('src', sTempSrc);
            }
        }
    }
}

addLoadEvent(initRollovers);



			$(document).ready(function() {
				var Browser = {
					a: navigator.userAgent.toLowerCase()
				}

				Browser = {
					ie: /*@cc_ontrue || @*/false,
					safari_ipad: Browser.a.indexOf('ipad') != -1, 
					ie6: Browser.a.indexOf('msie 6') != -1,
					ie7: Browser.a.indexOf('msie 7') != -1,
					ie8: Browser.a.indexOf('msie 8') != -1,
					opera: !!window.opera,
					safari: Browser.a.indexOf('safari') != -1,
					safari3: Browser.a.indexOf('applewebkit/5') != -1,
					mac: Browser.a.indexOf('mac') != -1,
					chrome: Browser.a.indexOf('chrome') != -1,
					firefox: Browser.a.indexOf('firefox') != -1
				}

				if ($("select").is(".myddsC")) {
					
					if (Browser.safari_ipad) {
						
						if (Browser.safari || Browser.safari3) {
							var test = $(".myddsC").length;
							for (i = 0; i < test; i++) {
								$(".myddsC").eq(i).css("width", ($(".myddsC").eq(i).width() + 20));
							}
						}
					}
					
					else if (Browser.safari || Browser.safari3) {
						if (!Browser.chrome) {
							var test = $(".myddsC").length;
							for (i = 0; i < test; i++) {
								$(".myddsC").eq(i).css("width", ($(".myddsC").eq(i).width() + 50));
							}
						}

					}

					$(".myddsC").msDropDown({ mainCSS: 'dc' });
				}
			})

function onDepth3(obj) {
           document.getElementById(obj).style.display = "block";
           document.getElementById(obj).style.zIndex = "1000";
}

function outDepth3(obj,m) {
           document.getElementById(obj).style.zIndex = "1";
           if (m){ 
                     document.getElementById(m).style.display = "block";
                     document.getElementById(m).style.zIndex = "2";
           }           
           if (m==''){
                     document.getElementById(obj).style.display = "none";
           }
}


function onDepth3_IR(obj, m) {
	if (obj != m) {
		document.getElementById(m).style.display = "none";
	}
	document.getElementById(obj).style.display = "block";
	document.getElementById(obj).style.zIndex = "1000";
}

function outDepth3_IR(obj, m) {

	document.getElementById(obj).style.display = "none";
	document.getElementById(obj).style.zIndex = "1";
	if (m) { 
		document.getElementById(m).style.display = "block";
		document.getElementById(m).style.zIndex = "2";
	}
	if (m == '') {
		document.getElementById(obj).style.display = "none";
	}
}

//LNB
$(document).ready(function(){
	$(".dep1 > li").bind('mouseenter',function() {
		$(this).children('ul').filter(":not(:animated)").slideDown("fast");
	});
});
$(document).ready(function(){
	$(".dep1 > li").bind('mouseleave',function() {
		if (!($(this).is(".on"))){
			$(this).children('ul').filter(":not(:animated)").slideUp("fast");
		};
	});
});



// image rolling
var TINY={};

function T$(i){return document.getElementById(i)}
function T$$(e,p){return p.getElementsByTagName(e)}

TINY.slider=function(){
	function slide(n,p){this.n=n; this.init(p)}
	slide.prototype.init=function(p){
		var s=T$(p.id), u=this.u=T$$('ul',s)[0], c=T$$('li',u), l=c.length, i=this.l=this.c=0;
		if(p.navid&&p.activeclass){this.g=T$$('li',T$(p.navid)); this.s=p.activeclass}
		this.a=p.auto||0; this.p=p.resume||0; this.v=p.vertical||0; s.style.overflow='hidden';
		for(i;i<l;i++){if(c[i].parentNode==u){this.l++}}
		if(this.v){;
			u.style.top=0; this.h=p.height||c[0].offsetHeight; u.style.height=(this.l*this.h)+'px'
		}else{
			u.style.left=0; this.w=p.width||c[0].offsetWidth; u.style.width=(this.l*this.w)+'px'
		}
		this.pos(p.position||0,this.a?1:0)
	},
	slide.prototype.auto=function(){
		this.u.ai=setInterval(new Function(this.n+'.move(1,1)'),this.a*1000)
	},
	slide.prototype.move=function(d,a){
		var n=this.c+d, i=d==1?n==this.l?0:n:n<0?this.l-1:n; this.pos(i,a)
	},
	slide.prototype.pos=function(p,a){
		clearInterval(this.u.ai); clearInterval(this.u.si);
		var o=this.v?parseInt(this.u.style.top):parseInt(this.u.style.left),
		t=this.v?p*this.h:p*this.w, d=t>Math.abs(o)?1:-1; t=t*-1; this.c=p;
		if(this.g){for(var i=0;i<this.l;i++){this.g[i].className=i==p?this.s:''}}
		this.u.si=setInterval(new Function(this.n+'.slide('+t+','+d+','+a+')'),20)
	},
	slide.prototype.slide=function(t,d,a){
		var o=this.v?parseInt(this.u.style.top):parseInt(this.u.style.left);
		if(o==t){
			clearInterval(this.u.si); if(a||(this.a&&this.p)){this.auto()}
		}else{
			var v=o-Math.ceil(Math.abs(t-o)*.15)*d+'px';
			this.v?this.u.style.top=v:this.u.style.left=v
		}
	};
	return{slide:slide}
}();



// jquery-slide-photo-paging
$.fn.extend({
	slideThumbnail: function(options) {
		return this.each(function() {
			new $.SlideThumbnail(this, options);
		});
	}
});

$.SlideThumbnail = function(slideobj, options) {

	var opt = options || {};
	opt.nextControl = opt.nextControl || '.after_view';
	opt.previousControl = opt.previousControl || '.before_view';
	opt.nextPageControl = opt.nextPageControl || '.next_page';
	opt.prevPageControl = opt.prevPageControl || '.prev_page';
	opt.firstControl = opt.firstControl || null,
	opt.lastControl = opt.lastControl || null,
	opt.moveElement = opt.moveElement || '.thumb_list ul';
	opt.thumbnails = opt.thumbnails || 'img';
	opt.orientation = opt.orientation || 'horizontal';
	opt.moveSize = opt.moveSize || 100;
	opt.viewCount = opt.viewCount || 1;
	opt.current = 0;
	opt.pagingElement = opt.pagingElement || '.direct_page';
	opt.page = 1;
	opt.pageCount = 10;

	var elem = slideobj;
	var $slideElem = $(slideobj);
	var $nextControl = $slideElem.find(opt.nextControl);
	var $previousControl = $slideElem.find(opt.previousControl);
	var $nextPageControl = $slideElem.find(opt.nextPageControl);
	var $prevPageControl = $slideElem.find(opt.prevPageControl);
	var $firstControl = $slideElem.find(opt.firstControl);
	var $lastControl = $slideElem.find(opt.lastControl);
	var $moveElement = $slideElem.find(opt.moveElement);
	var thumbnails = $slideElem.find(opt.thumbnails);
	var current = opt.current;

	var pagingElem = $slideElem.find(opt.pagingElement);
	var page = opt.page;
	var totalCount = thumbnails.length;
	var totalPage = parseInt((totalCount - 1) / opt.viewCount) + 1;
	var firstPage;
	var lastPage;

//	alert('totalCount='+totalCount);
//	alert('totalPage='+totalPage);

	//paging(page);

	function paging(index) {

		movePhoto((index - 1) * opt.viewCount);
		var first = (index -1) * opt.viewCount;
		var last = index * opt.viewCount;
		if(totalCount < last) last = totalCount;
		if(last<1) last = 0;

		firstPage = parseInt((index - 1) / opt.pageCount + 1) * opt.pageCount - (opt.pageCount - 1);
		lastPage = firstPage + opt.pageCount - 1;
		if(lastPage > totalPage) lastPage = totalPage;

		pagingElem.empty();

		for(i = firstPage; i <= lastPage; i++) {
			var a = document.createElement('a');
			var $a = $(a);
			if(index == i) $a.attr('class', 'current_page');
			$a.addClass('direct_move');
			$a.attr('href', '#none');
			$a.text(i);
			pagingElem.append(a);
		}

		pagingElem.find('.direct_move').each(function(n) {
			$(this).click(function() {
				paging($(this).text());
			});
		});
		return page = index;

	}

	$prevPageControl.click(function() {
		if(page > opt.pageCount) {
			paging(firstPage - 1);
		}
	});
	$nextPageControl.click(function() {
		next = lastPage + 1;
		if(next <= totalPage) {
			paging(next);
		}
	});
	$firstControl.click(function() {
		paging(1);
	});

	$previousControl.click(function() {
		if(current > 0) {
			movePhoto((thumbnails.length + current -1) % thumbnails.length);
			if((current % opt.viewCount) == 0) {
				paging((current / opt.viewCount) + 1);
			}
		}
	});
	$nextControl.click(function() {
		if(current + opt.viewCount < thumbnails.length) {
			movePhoto((current + 1) % thumbnails.length);
			if((current % opt.viewCount) == 0) {
				paging((current / opt.viewCount) + 1);
			}
		}
	});

	$lastControl.click(function() {
		paging(totalPage);
	});

	function movePhoto(index) {
		if(opt.orientation == 'horizontal') {
			$moveElement.animate({left:opt.moveSize * index}, 'slow');
		} else {
			$moveElement.animate({top:opt.moveSize * index}, 'slow');
		}
		current = index;
		buttonAction(index);
	}

	function buttonAction() {
		if(current > 0) {
			$previousControl.find('img').attr('src', function() {return this.src.replace('_off', '_on');});
			$previousControl.addClass('on');
			$previousControl.removeClass('off');
		} else {
			$previousControl.find('img').attr('src', function() {return this.src.replace('_on', '_off');});
			$previousControl.addClass('off');
			$previousControl.removeClass('on');
		}
		if(current + opt.viewCount < thumbnails.length) {
			$nextControl.find('img').attr('src', function() {return this.src.replace('_off', '_on');});
			$nextControl.addClass('on');
			$nextControl.removeClass('off');
		} else {
			$nextControl.find('img').attr('src', function() {return this.src.replace('_on', '_off');});
			$nextControl.addClass('off');
			$nextControl.removeClass('on');
		}
	}
}



function viewTxt(obj) {
	document.getElementById(obj).style.display = "block";
}

function viewTxtOut(obj) {
	document.getElementById(obj).style.display = "none";
}



function showHideElem1(_objId, _param_split){
	var showObj = document.getElementById(_objId);
	if(!showObj) return false;
	if(_param_split){
		var hideObjId_arr = _param_split.split("_");
		var hideObj_arr = Array();
		for(i=0; i<hideObjId_arr.length; i++){
			hideObj_arr[i] = document.getElementById(hideObjId_arr[i]);
		}
		for(i=0; i<hideObj_arr.length; i++){
			if(hideObj_arr[i].style){
				hideObj_arr[i].style.display = "none";
			}else{
				return false;
			}
		}
		showObj.style.display = "block";
	}
	else{
		if(showObj.style.display == "block"){
			showObj.style.display = "none";
		}else{
			showObj.style.display = "block";
		}
	}
}



			var num = 1;
			function slider_list(n){
				if (n == "prev"){
					if (num == 1){
						num = $(".slider_dot img").length;			
					}else{
						num = num - 1;
					}
					n = num
				}
				
				if (n == "next"){
					if (num < $(".slider_dot img").length)
					{
						num = num +1;
					}else{
						num = 1
					}
					n = num
				}
				$(".slider_list ul").animate({ "left":"-"+$(".slider_list ul li").eq(n-1).position().left  }, "slow");

				for (i=1; i <= $(".slider_dot img").length ; i++ ){
					if (i == n){
						imgname = $(".slider_dot img").eq(i-1).attr("src").split("off")[0];
						imgtype = $(".slider_dot img").eq(i-1).attr("src").split("off")[1];
						if (String(imgname).length<35){
							$(".slider_dot img").eq(i-1).attr("src",imgname+"on"+imgtype);
						}
						
					}else{
						if ($(".slider_dot img").eq(i-1).attr("src").indexOf("on") > 0){
							imgname = $(".slider_dot img").eq(i-1).attr("src").split("on")[0];
							imgtype = $(".slider_dot img").eq(i-1).attr("src").split("on")[1];
							$(".slider_dot img").eq(i-1).attr("src",imgname+"off"+imgtype);
						}
					}
				}
				num = n;
			}


$(function() {
$("img.tabon").mouseover(function() {
$(this).attr("src", $(this).attr("src").replace("off","on"));

});
$("img.tabon").mouseout(function() {
$(this).attr("src", $(this).attr("src").replace("on", "off"));
});
});




// FOOTER FAMILY SITE

$(document).ready(function(){
	$(".open, .close").click(function(){
		$(".slide, .ieif").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
});